using System;
using System.Collections.Generic;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using Microsoft.SharePoint;

namespace zevenseas.Community.Web.UI.WebControls.WebParts
{
    public class ChangePassword35Editor : EditorPart
    {
        private TextBox domain;                
        private Panel toolPanePanel;

        protected override void CreateChildControls()
        {
            Title = "ChangePassword Configuration";
            toolPanePanel = new Panel();
            toolPanePanel.Attributes.CssStyle.Add("padding-left", "5px");
            toolPanePanel.Attributes.CssStyle.Add("padding-top", "5px");
            Controls.Add(toolPanePanel);

            toolPanePanel.Controls.Add(new LiteralControl("<BR>Domain, this is where you specify the LDAP string. An example is 'litwareinc.com' or 'intranet.com'</br>"));
            domain = new TextBox();
            toolPanePanel.Controls.Add(domain);
                       
            
            if (ViewState["DomainName"] == null)
            {
                ViewState["DomainName"] = domain.Text.ToString();                
            }
            
            TagLine productTagLine = new TagLine();
            productTagLine.ProductName = "ChangePasswordNET35";
            productTagLine.ProductId = "89";
            toolPanePanel.Controls.Add(productTagLine);

            base.CreateChildControls();
        }
        

        public override bool ApplyChanges()
        {
            EnsureChildControls();

            ChangePasswordNET35 webPart = WebPartToEdit as ChangePasswordNET35; 
            
            if (webPart != null)
            {
                webPart.Domain = domain.Text.ToString();                
            }
            return true;
        }

        public override void SyncChanges()
        {
            EnsureChildControls();
            ChangePasswordNET35 webPart = WebPartToEdit as ChangePasswordNET35;

            if (webPart != null && !string.IsNullOrEmpty(webPart.Domain))
            {
                domain.Text = webPart.Domain;                
            }
        }
    }
}